package hot100;

import DTO.TreeNode;

public class kthSmallest {
    //cur=k判断第几小, ret返回值
    int cur;
    int ret;
    public int kthSmallest(TreeNode root, int k) {
        cur = k;
        dfs(root);
        return ret;

    }

    void dfs(TreeNode root) {
        if(root == null || cur == 0) {
            return;
        }
        dfs(root.left);
        cur--;
        if(cur == 0){
            ret = root.val;
            return;
        }
        dfs(root.right);

    }
}
